package cn.smart.epic.common.constant.dictmap.factory;

import cn.smart.epic.common.constant.dictmap.base.AbstractDictMap;
import cn.smart.epic.common.constant.dictmap.base.SystemDict;
import cn.smart.epic.common.exception.BizExceptionEnum;
import cn.smart.epic.common.exception.BussinessException;

/**
 * @Auther Uncle_Z
 * @date 2017/10/4 0:03
 * @Email:2545375@qq.com
 * @Descrition 字典的创建工厂
 * @since 1.0
 */

public class DictMapFactory {

    private static final String basePath = "cn.smart.epic.common.constant.dictmap.";

    /**
     * 通过类名创建具体的字典类
     * @param className
     * @return
     */
    public static AbstractDictMap createDictMap(String className){
        if("SystemDict".equals(className)) {
            return new SystemDict();
        }else{
            try{
                Class<AbstractDictMap> clazz =(Class<AbstractDictMap>) Class.forName(basePath+className);
                return clazz.newInstance();
            }catch (Exception e){
                throw new BussinessException(BizExceptionEnum.ERROR_CREATE_DICT);
            }
        }
    }
}
